$(function() {
  //$('.zp-head').imagefill();
  var ul = $('.article-list');
  var isProcessing = false,
    curIndex = 0,
    maxIndex = ul.children().length - 3,
    moveStep = 330;

  function _move(direction) {
    if (isProcessing) {
      return;
    }
    if(curIndex == 0 && direction < 0 ){
      return;
    }
    if(curIndex == maxIndex && direction > 0){
      return;
    }

    isProcessing = true;
    var _left = -curIndex*moveStep - moveStep*direction;
    ul.animate({
        marginLeft: _left
      },
      400, function() {
        curIndex += direction;
        console.log('cur index - > ',curIndex);
        isProcessing = false;
      });
  }
  if (ul.children().length > 3) {
    $('.prev,.next').click(function() {
      var direction = $(this).hasClass('prev') ? -1 : 1;
      console.log(direction,":",maxIndex);
      _move(direction);
      
    });
  } else {
    $('#article .next,#article .prev').hide();
  }
});